{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "id": "F1ECBA83A55745518FE950BF2C87686E",
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/opt/conda/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88\n",
      "  return f(*args, **kwds)\n",
      "/opt/conda/lib/python3.6/site-packages/matplotlib/font_manager.py:232: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.\n",
      "  'Matplotlib is building the font cache using fc-list. '\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "94C6543455964CAD887C652C0C1CEFAB",
    "mdEditEnable": false
   },
   "source": [
    "### 1. 数据导入"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "id": "9641268217634D1D813EEDE545C65A3E",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "city_road = pd.read_csv('/home/kesci/input/Country_Road5135/city_roads.csv')\n",
    "taiwan_road = pd.read_csv('/home/kesci/input/Country_Road5135/taiwan_roads.csv')\n",
    "city_data = pd.read_csv('/home/kesci/input/Country_Road5135/city_data.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "id": "BF52F83FBA1F4ACD9A36C0063FE96EB8",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>39153</th>\n",
       "      <td>广州</td>\n",
       "      <td>YM01-新合路                                      ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48584</th>\n",
       "      <td>杭州</td>\n",
       "      <td>荏山路                                           ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72967</th>\n",
       "      <td>茂名</td>\n",
       "      <td>广海公路                                          ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131063</th>\n",
       "      <td>无锡</td>\n",
       "      <td>沅泾路                                           ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19167</th>\n",
       "      <td>常州</td>\n",
       "      <td>潘丰路                                           ...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       city                                               road\n",
       "39153    广州  YM01-新合路                                      ...\n",
       "48584    杭州  荏山路                                           ...\n",
       "72967    茂名  广海公路                                          ...\n",
       "131063   无锡  沅泾路                                           ...\n",
       "19167    常州  潘丰路                                           ..."
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_road.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "id": "CD0C91730E0F4EB980328A895012929D",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "city_road['road'] = city_road['road'].str.strip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "id": "BC14D16E805F4B2B83898B54A6EC21FB",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>34276</th>\n",
       "      <td>佛山</td>\n",
       "      <td>义学街</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54185</th>\n",
       "      <td>海口</td>\n",
       "      <td>金濂路</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13144</th>\n",
       "      <td>成都</td>\n",
       "      <td>茂达街</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>39520</th>\n",
       "      <td>广州</td>\n",
       "      <td>Y903-利丰大道</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17532</th>\n",
       "      <td>长春</td>\n",
       "      <td>绿园街</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      city       road\n",
       "34276   佛山        义学街\n",
       "54185   海口        金濂路\n",
       "13144   成都        茂达街\n",
       "39520   广州  Y903-利丰大道\n",
       "17532   长春        绿园街"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_road.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "id": "923E1560CFD0401C8E983C133013F25C",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6217</th>\n",
       "      <td>云林县</td>\n",
       "      <td>四维街</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12664</th>\n",
       "      <td>新竹县</td>\n",
       "      <td>工业四路</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15081</th>\n",
       "      <td>彰化县</td>\n",
       "      <td>三成村小西路</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27275</th>\n",
       "      <td>云林县</td>\n",
       "      <td>北糖四街</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2112</th>\n",
       "      <td>高雄市</td>\n",
       "      <td>溪寮路２段</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      city    road\n",
       "6217   云林县     四维街\n",
       "12664  新竹县    工业四路\n",
       "15081  彰化县  三成村小西路\n",
       "27275  云林县    北糖四街\n",
       "2112   高雄市   溪寮路２段"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "taiwan_road.sample(5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "530AF99A7BBC4A1E8F3472F877F2A442",
    "mdEditEnable": false
   },
   "source": [
    "### 2. 数据清洗\n",
    "1. 清洗出包含“街”、“道”、“巷”、“路”的道路\n",
    "2. 增加字段“province”表示城市所在的省份\n",
    "3. 把台湾的数据合并进来\n",
    "4. 去重\n",
    "5. 清除杂乱的字符"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "9283783C64CD4D7A8DB3EB504CCF190D",
    "mdEditEnable": false
   },
   "source": [
    "#### 2.1 清洗出包含“街”、“道”、“巷”、“路”的道路"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "id": "C8829D6B8E3C411786FFB93694ECB1C8",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "    city_road = city_road[(city_road['road'].str.contains(\n",
    "        '胡同|巷|街|路|道')) | (city_road['road'].str.endswith('里'))]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "D294F2AB9B634E58828398C3A9400606",
    "mdEditEnable": false
   },
   "source": [
    "#### 2.2 增加字段“province_short”表示城市所在的省份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "id": "1C1CF732E3D04A4782AB4CC8DD251936",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>province</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>129</th>\n",
       "      <td>和龙</td>\n",
       "      <td>吉林省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>326</th>\n",
       "      <td>蓬莱</td>\n",
       "      <td>山东省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>232</th>\n",
       "      <td>铜陵</td>\n",
       "      <td>安徽省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>281</th>\n",
       "      <td>瑞昌</td>\n",
       "      <td>江西省</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>531</th>\n",
       "      <td>彭州</td>\n",
       "      <td>四川省</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    city province\n",
       "129   和龙      吉林省\n",
       "326   蓬莱      山东省\n",
       "232   铜陵      安徽省\n",
       "281   瑞昌      江西省\n",
       "531   彭州      四川省"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_data.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "id": "2A78124F72D7459B8CC15DB6D4D6222F",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['河北省', '山西省', '内蒙古自治区', '辽宁省', '吉林省', '黑龙江省', '江苏省', '浙江省', '安徽省',\n",
       "       '福建省', '江西省', '山东省', '河南省', '湖北省', '湖南省', '广东省', '广西壮族自治区', '海南省',\n",
       "       '四川省', '贵州省', '云南省', '陕西省', '甘肃省', '青海省', '西藏自治区', '宁夏回族自治区', '台湾',\n",
       "       '北京市', '天津市', '上海市', '重庆市', '香港', '澳门', '新疆维吾尔自治区'], dtype=object)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_data['province'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "id": "76CF5280A4504E0DB3241B192FE7CB36",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "city_data['province_short'] = city_data['province'].str.replace(\n",
    "    \"省|市|维吾尔自治区|壮族自治区|回族自治区|自治区\", \"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "id": "702AAD4DDAE64E139F05409700CD3334",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "city_road = city_road.merge(city_data[['city', 'province_short']], how='left', on='city')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "id": "29B8A017CC1246EB82F4555C2B31DA50",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>70137</th>\n",
       "      <td>南平</td>\n",
       "      <td>杭头街</td>\n",
       "      <td>福建</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95101</th>\n",
       "      <td>宿迁</td>\n",
       "      <td>井马线路</td>\n",
       "      <td>江苏</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4300</th>\n",
       "      <td>北京</td>\n",
       "      <td>前章村西路</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25102</th>\n",
       "      <td>福州</td>\n",
       "      <td>红湖中路</td>\n",
       "      <td>福建</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96439</th>\n",
       "      <td>绍兴</td>\n",
       "      <td>雍平支路</td>\n",
       "      <td>浙江</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      city   road province_short\n",
       "70137   南平    杭头街             福建\n",
       "95101   宿迁   井马线路             江苏\n",
       "4300    北京  前章村西路             北京\n",
       "25102   福州   红湖中路             福建\n",
       "96439   绍兴   雍平支路             浙江"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_road.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "id": "A36958257E314B6B8ADE71034F617B6F",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "taiwan_road['province_short'] = '台湾'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "id": "F17431C5CE574B78B9922E698E317786",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "taiwan_road['city'] = taiwan_road['city'].str.replace('县|市', '')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "62969654FB644B809E25A5C0E714E48F",
    "mdEditEnable": false
   },
   "source": [
    "#### 2.3 把台湾的数据合并进来"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "id": "1A136C07F6734F1697F7FEAD7B690567",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "data = pd.concat([city_road, taiwan_road])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "id": "6C8F93E8D96C47A0899B163A17313B85",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>110169</th>\n",
       "      <td>无锡</td>\n",
       "      <td>长安东街</td>\n",
       "      <td>江苏</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51468</th>\n",
       "      <td>金华</td>\n",
       "      <td>解放中街</td>\n",
       "      <td>浙江</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15671</th>\n",
       "      <td>新北</td>\n",
       "      <td>中山路２段</td>\n",
       "      <td>台湾</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>43</th>\n",
       "      <td>安阳</td>\n",
       "      <td>阜民街</td>\n",
       "      <td>河南</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135340</th>\n",
       "      <td>重庆</td>\n",
       "      <td>平安三路</td>\n",
       "      <td>重庆</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       city   road province_short\n",
       "110169   无锡   长安东街             江苏\n",
       "51468    金华   解放中街             浙江\n",
       "15671    新北  中山路２段             台湾\n",
       "43       安阳    阜民街             河南\n",
       "135340   重庆   平安三路             重庆"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sample(5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "31D44631A4DF404880A9EF9F81E33C05",
    "mdEditEnable": false
   },
   "source": [
    "#### 2.4 去除重复数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "id": "B52D7050CEA646CDA3906FC7C2E7FBA0",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "data.drop_duplicates(inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "id": "9E5BD4822C4C4C4B880747979BD8418B",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>83131</th>\n",
       "      <td>上海</td>\n",
       "      <td>沁春路</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78823</th>\n",
       "      <td>上海</td>\n",
       "      <td>奥伟路</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>84039</th>\n",
       "      <td>上海</td>\n",
       "      <td>天钥桥南路</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78820</th>\n",
       "      <td>上海</td>\n",
       "      <td>安东路</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82847</th>\n",
       "      <td>上海</td>\n",
       "      <td>南宅路</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      city   road province_short\n",
       "83131   上海    沁春路             上海\n",
       "78823   上海    奥伟路             上海\n",
       "84039   上海  天钥桥南路             上海\n",
       "78820   上海    安东路             上海\n",
       "82847   上海    南宅路             上海"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data['city']=='上海'].sample(5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "2F5FBCE6A95B461A80675AF6280FB446",
    "mdEditEnable": false
   },
   "source": [
    "#### 2.5 清除杂乱的字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "id": "F696EDD0E66842BAAFB4F8702E63C36C",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# 去除高速公路、隧道\n",
    "data = data[-data['road'].str.contains('G|隧道|高速')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "id": "8AE3475014004B0A80DC9DA580D00B5D",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>53161</th>\n",
       "      <td>江门</td>\n",
       "      <td>德汉街</td>\n",
       "      <td>广东</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>107784</th>\n",
       "      <td>铜仁</td>\n",
       "      <td>川侗南路</td>\n",
       "      <td>贵州</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5267</th>\n",
       "      <td>高雄</td>\n",
       "      <td>镇川五巷</td>\n",
       "      <td>台湾</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>135291</th>\n",
       "      <td>重庆</td>\n",
       "      <td>南天湖西路</td>\n",
       "      <td>重庆</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131978</th>\n",
       "      <td>宜宾</td>\n",
       "      <td>铁肩街</td>\n",
       "      <td>四川</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       city   road province_short\n",
       "53161    江门    德汉街             广东\n",
       "107784   铜仁   川侗南路             贵州\n",
       "5267     高雄   镇川五巷             台湾\n",
       "135291   重庆  南天湖西路             重庆\n",
       "131978   宜宾    铁肩街             四川"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "id": "88D845B3C4544A7086EC10015294B513",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# 去除X***字符\n",
    "data.loc[data['road'].str.contains('-'), 'road'] = data.loc[data['road'].str.contains('-'), 'road'].str.split('-', expand=True)[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "id": "4AEEE7DB20954C8A8236A80AE83E9440",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>15119</th>\n",
       "      <td>彰化</td>\n",
       "      <td>斗苑路顶后段</td>\n",
       "      <td>台湾</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16321</th>\n",
       "      <td>台东</td>\n",
       "      <td>龙三路</td>\n",
       "      <td>台湾</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17078</th>\n",
       "      <td>屏东</td>\n",
       "      <td>龙湾巷</td>\n",
       "      <td>台湾</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87032</th>\n",
       "      <td>上海</td>\n",
       "      <td>恒南路</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>117407</th>\n",
       "      <td>渭南</td>\n",
       "      <td>岳庙东街</td>\n",
       "      <td>陕西</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       city    road province_short\n",
       "15119    彰化  斗苑路顶后段             台湾\n",
       "16321    台东     龙三路             台湾\n",
       "17078    屏东     龙湾巷             台湾\n",
       "87032    上海     恒南路             上海\n",
       "117407   渭南    岳庙东街             陕西"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "id": "BDDCADB7769045FF92DE1EA145F4C325",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(151174, 3)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "C5E6AA9538E046839D49F0961A10A973",
    "mdEditEnable": false
   },
   "source": [
    "### 3. 问题\n",
    "1. 哪些省份/城市在道路名中出镜率最高？\n",
    "2. 哪些城市热衷于使用其它城市名作为道路名？\n",
    "3. 街、道、路、巷、胡同、里有何不同？\n",
    "4. 各城市都有“建设路”吗？还有哪些具有时代特色的路名？\n",
    "5. 体现人们美好愿望的路名？\n",
    "6. 体现区域地理的路名？\n",
    "7. 体现儒释道特色的路名？\n",
    "8. 体现周围景观的路名？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "96388D68A6AB48FEAF206C607545A285",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.1 哪些省份/城市在道路名中出镜率最高？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "id": "66DD3793CD4F4C55803EBB5E46E5A13B",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>province</th>\n",
       "      <th>province_short</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>石家庄</td>\n",
       "      <td>河北省</td>\n",
       "      <td>河北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>邯郸</td>\n",
       "      <td>河北省</td>\n",
       "      <td>河北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>唐山</td>\n",
       "      <td>河北省</td>\n",
       "      <td>河北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>保定</td>\n",
       "      <td>河北省</td>\n",
       "      <td>河北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>秦皇岛</td>\n",
       "      <td>河北省</td>\n",
       "      <td>河北</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  city province province_short\n",
       "0  石家庄      河北省             河北\n",
       "1   邯郸      河北省             河北\n",
       "2   唐山      河北省             河北\n",
       "3   保定      河北省             河北\n",
       "4  秦皇岛      河北省             河北"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "99DBB89DE44C4C44AEC26CF527F1CB26",
    "mdEditEnable": false
   },
   "source": [
    "##### 3.1.1 出境最多的省份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "id": "77218E8D3F59417A88179859182B74F5",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "province = list(city_data['province_short'].unique())\n",
    "province_join = '|'.join(province)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "id": "A7D0C5A6830244E5963E905041BA34B7",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "山东     319\n",
       "山西     281\n",
       "河南     230\n",
       "河北     218\n",
       "江西     156\n",
       "湖南     130\n",
       "湖北     126\n",
       "北京      62\n",
       "海南      52\n",
       "上海      50\n",
       "云南      45\n",
       "重庆      42\n",
       "天津      39\n",
       "吉林      33\n",
       "陕西      30\n",
       "青海      27\n",
       "广东      27\n",
       "宁夏      23\n",
       "四川      23\n",
       "香港      20\n",
       "福建      19\n",
       "贵州      18\n",
       "辽宁      16\n",
       "黑龙江     15\n",
       "浙江      14\n",
       "广西      14\n",
       "江苏      14\n",
       "新疆      10\n",
       "澳门      10\n",
       "甘肃       8\n",
       "西藏       8\n",
       "台湾       6\n",
       "安徽       5\n",
       "内蒙古      1\n",
       "Name: 0, dtype: int64"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['road'].str.extract(r\"({})\".format(province_join))[0].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "id": "D56339D906D2430E80726DAFA4F88692",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>112037</th>\n",
       "      <td>无锡</td>\n",
       "      <td>香山东路</td>\n",
       "      <td>江苏</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2463</th>\n",
       "      <td>北京</td>\n",
       "      <td>房山东大街</td>\n",
       "      <td>北京</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87399</th>\n",
       "      <td>上海</td>\n",
       "      <td>中山东二路</td>\n",
       "      <td>上海</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68049</th>\n",
       "      <td>宁波</td>\n",
       "      <td>教场山东路</td>\n",
       "      <td>浙江</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88613</th>\n",
       "      <td>沈阳</td>\n",
       "      <td>十三纬路山东庙巷</td>\n",
       "      <td>辽宁</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       city      road province_short\n",
       "112037   无锡      香山东路             江苏\n",
       "2463     北京     房山东大街             北京\n",
       "87399    上海     中山东二路             上海\n",
       "68049    宁波     教场山东路             浙江\n",
       "88613    沈阳  十三纬路山东庙巷             辽宁"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 探索了一圈，发现很多是以“X山东X”这种格式的，并不是以山东省名称命名，只是恰好路名里带“山东”两个字\n",
    "# 其它包括山西、河南、河北、江西、湖南、湖北、海南等都是如此，所以还得要以省份开头\n",
    "data[data['road'].str.contains('山东')].sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "id": "6C4CACE548544370902807C6E469BBBC",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "data['prov_ext'] = data['road'].str.extract(r\"\\b({})\".format(province_join))[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "id": "E7DA7682885847C49D4D8057CAAF69C6",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "      <th>prov_ext</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>117808</th>\n",
       "      <td>乌鲁木齐</td>\n",
       "      <td>河南东路南二巷</td>\n",
       "      <td>新疆</td>\n",
       "      <td>河南</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29612</th>\n",
       "      <td>台中</td>\n",
       "      <td>河南东五街</td>\n",
       "      <td>台湾</td>\n",
       "      <td>河南</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29614</th>\n",
       "      <td>台中</td>\n",
       "      <td>河南路</td>\n",
       "      <td>台湾</td>\n",
       "      <td>河南</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20127</th>\n",
       "      <td>苗栗</td>\n",
       "      <td>河南街</td>\n",
       "      <td>台湾</td>\n",
       "      <td>河南</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29616</th>\n",
       "      <td>台中</td>\n",
       "      <td>河南路２段</td>\n",
       "      <td>台湾</td>\n",
       "      <td>河南</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        city     road province_short prov_ext\n",
       "117808  乌鲁木齐  河南东路南二巷             新疆       河南\n",
       "29612     台中    河南东五街             台湾       河南\n",
       "29614     台中      河南路             台湾       河南\n",
       "20127     苗栗      河南街             台湾       河南\n",
       "29616     台中    河南路２段             台湾       河南"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data['prov_ext']=='河南'].sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "id": "06669249640E477D9B86F1BA2EE74978",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "北京    61\n",
       "上海    49\n",
       "河北    47\n",
       "河南    46\n",
       "重庆    41\n",
       "天津    39\n",
       "吉林    32\n",
       "陕西    29\n",
       "青海    27\n",
       "广东    25\n",
       "Name: prov_ext, dtype: int64"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "prov_top10 = data['prov_ext'].value_counts()[:10]\n",
    "prov_top10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "id": "2CBF0F7D05314D5286F2A37BD1F233D3",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"a7ba696b9f21424986f1cb1e60809a47\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_a7ba696b9f21424986f1cb1e60809a47 = echarts.init(document.getElementById('a7ba696b9f21424986f1cb1e60809a47'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_a7ba696b9f21424986f1cb1e60809a47 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8def\\u540d\\u4e2d\\u51fa\\u955c\\u7387\\u6700\\u9ad8\\u7684\\u7701\\u7ea7\\u884c\\u653f\\u5355\\u4f4d\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d:\\u6b21\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 1433858,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                61.0,\n",
       "                49.0,\n",
       "                47.0,\n",
       "                46.0,\n",
       "                41.0,\n",
       "                39.0,\n",
       "                32.0,\n",
       "                29.0,\n",
       "                27.0,\n",
       "                25.0\n",
       "            ],\n",
       "            \"stack\": \"stack_1433858\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 1433858\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5317\\u4eac\",\n",
       "                \"\\u4e0a\\u6d77\",\n",
       "                \"\\u6cb3\\u5317\",\n",
       "                \"\\u6cb3\\u5357\",\n",
       "                \"\\u91cd\\u5e86\",\n",
       "                \"\\u5929\\u6d25\",\n",
       "                \"\\u5409\\u6797\",\n",
       "                \"\\u9655\\u897f\",\n",
       "                \"\\u9752\\u6d77\",\n",
       "                \"\\u5e7f\\u4e1c\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_a7ba696b9f21424986f1cb1e60809a47.setOption(option_a7ba696b9f21424986f1cb1e60809a47);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e5f43390>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import Bar\n",
    "\n",
    "bar = Bar(\"路名中出镜率最高的省级行政单位\",\"单位:次\", width = 600,height=500)\n",
    "bar.add(\"\", prov_top10.index, prov_top10.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=20, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside')\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "id": "B02C164ECAFF40838CE21198FB258291",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "def get_unique_city_count(data):\n",
    "    return len(data.unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "id": "62043D90091F456CB917F746633FAF31",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "prov_ext\n",
       "上海    28\n",
       "北京    28\n",
       "天津    24\n",
       "河南    24\n",
       "河北    21\n",
       "吉林    19\n",
       "山东    18\n",
       "重庆    18\n",
       "广东    14\n",
       "青海    14\n",
       "Name: city, dtype: int64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.groupby('prov_ext')['city'].apply(get_unique_city_count).nlargest(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "69FDE6418CA140D38B245183989BEE7F",
    "mdEditEnable": false
   },
   "source": [
    "##### 3.1.2 出镜最多的城市"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "id": "7BEDD81C059C491A88FCB4F31D345E10",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>中文名</th>\n",
       "      <th>citycode</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>371</th>\n",
       "      <td>桃园市</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>131</th>\n",
       "      <td>抚州市</td>\n",
       "      <td>794</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>333</th>\n",
       "      <td>西宁市</td>\n",
       "      <td>971</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>367</th>\n",
       "      <td>可克达拉市</td>\n",
       "      <td>1999</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>190</th>\n",
       "      <td>常德市</td>\n",
       "      <td>736</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       中文名  citycode\n",
       "371    桃园市         0\n",
       "131    抚州市       794\n",
       "333    西宁市       971\n",
       "367  可克达拉市      1999\n",
       "190    常德市       736"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_data2 = pd.read_csv('/home/kesci/input/Country_Road5135/citycode2.csv')\n",
    "city_data2.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "id": "39EBF151461E4D548B4E1A1AD44AA5AA",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "city_data2['中文名'] = city_data2['中文名'].str.replace('市', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "id": "D30C03BD929446F39767AFECE913559F",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>中文名</th>\n",
       "      <th>citycode</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>108</th>\n",
       "      <td>宿州</td>\n",
       "      <td>557</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>308</th>\n",
       "      <td>阿里</td>\n",
       "      <td>897</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>日照</td>\n",
       "      <td>633</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105</th>\n",
       "      <td>黄山</td>\n",
       "      <td>559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>276</th>\n",
       "      <td>凉山</td>\n",
       "      <td>834</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    中文名  citycode\n",
       "108  宿州       557\n",
       "308  阿里       897\n",
       "143  日照       633\n",
       "105  黄山       559\n",
       "276  凉山       834"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_data2.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "id": "C484CDD388DC4E839F3D5937775166B5",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "city = list(city_data2['中文名'].unique())\n",
    "city_join = '|'.join(city)\n",
    "data['city_ext'] = data['road'].str.extract(r\"\\b({})\".format(city_join))[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "id": "E21F8382334F4D8E93683C0CDCDABDFD",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "中山    366\n",
       "朝阳    167\n",
       "大同    133\n",
       "文昌    125\n",
       "长春    103\n",
       "东方     89\n",
       "桃园     63\n",
       "北京     61\n",
       "兴安     59\n",
       "南京     58\n",
       "南昌     54\n",
       "上海     49\n",
       "Name: city_ext, dtype: int64"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_top12 = data['city_ext'].value_counts()[:12]\n",
    "city_top12"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "id": "0026BE3CCB0548CA8B4054E663CE58B6",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"bcafb4037ec74e31a7e5a29f52b1afd4\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_bcafb4037ec74e31a7e5a29f52b1afd4 = echarts.init(document.getElementById('bcafb4037ec74e31a7e5a29f52b1afd4'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_bcafb4037ec74e31a7e5a29f52b1afd4 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8def\\u540d\\u4e2d\\u51fa\\u955c\\u7387\\u6700\\u9ad8\\u7684\\u57ce\\u5e02\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d:\\u6b21\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 873650,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                366.0,\n",
       "                167.0,\n",
       "                133.0,\n",
       "                125.0,\n",
       "                103.0,\n",
       "                89.0,\n",
       "                63.0,\n",
       "                61.0,\n",
       "                59.0,\n",
       "                58.0,\n",
       "                54.0,\n",
       "                49.0\n",
       "            ],\n",
       "            \"stack\": \"stack_873650\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 873650\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u4e2d\\u5c71\",\n",
       "                \"\\u671d\\u9633\",\n",
       "                \"\\u5927\\u540c\",\n",
       "                \"\\u6587\\u660c\",\n",
       "                \"\\u957f\\u6625\",\n",
       "                \"\\u4e1c\\u65b9\",\n",
       "                \"\\u6843\\u56ed\",\n",
       "                \"\\u5317\\u4eac\",\n",
       "                \"\\u5174\\u5b89\",\n",
       "                \"\\u5357\\u4eac\",\n",
       "                \"\\u5357\\u660c\",\n",
       "                \"\\u4e0a\\u6d77\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_bcafb4037ec74e31a7e5a29f52b1afd4.setOption(option_bcafb4037ec74e31a7e5a29f52b1afd4);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e50d3198>"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"路名中出镜率最高的城市\",\"单位:次\", width = 600,height=500)\n",
    "bar.add(\"\", city_top12.index, city_top12.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=20, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside')\n",
    "bar"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "73E2BD7EA6C342E381FDD2D4CA87F8C9",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.2 哪些城市热衷于使用其它城市名作为道路名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "id": "0C50786D203444F2B9E8C074CB8F76AB",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>city</th>\n",
       "      <th>road</th>\n",
       "      <th>province_short</th>\n",
       "      <th>prov_ext</th>\n",
       "      <th>city_ext</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>119871</th>\n",
       "      <td>西安</td>\n",
       "      <td>兴中路</td>\n",
       "      <td>陕西</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14522</th>\n",
       "      <td>高雄</td>\n",
       "      <td>三和路</td>\n",
       "      <td>台湾</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22505</th>\n",
       "      <td>台中</td>\n",
       "      <td>太平八街</td>\n",
       "      <td>台湾</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102977</th>\n",
       "      <td>天津</td>\n",
       "      <td>老左营路</td>\n",
       "      <td>天津</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119563</th>\n",
       "      <td>西安</td>\n",
       "      <td>尚朴路</td>\n",
       "      <td>陕西</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       city  road province_short prov_ext city_ext\n",
       "119871   西安   兴中路             陕西      NaN      NaN\n",
       "14522    高雄   三和路             台湾      NaN      NaN\n",
       "22505    台中  太平八街             台湾      NaN      NaN\n",
       "102977   天津  老左营路             天津      NaN      NaN\n",
       "119563   西安   尚朴路             陕西      NaN      NaN"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "id": "33EE082B2184492093644FF1B19314F2",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "city\n",
       "青岛      131\n",
       "上海       89\n",
       "台北       69\n",
       "天津       64\n",
       "桃园       57\n",
       "高雄       56\n",
       "长春       54\n",
       "屏东       49\n",
       "沈阳       43\n",
       "台东       42\n",
       "台中       42\n",
       "苏州       41\n",
       "乌鲁木齐     39\n",
       "烟台       39\n",
       "云林       35\n",
       "Name: city_ext, dtype: int64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_counts = data.groupby('city')['city_ext'].apply(get_unique_city_count).nlargest(15)\n",
    "city_counts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {
    "id": "5A658B69F3B94F3C87623BF3012A945E",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"463856212d1347558d919e4e179932db\" style=\"width:800px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_463856212d1347558d919e4e179932db = echarts.init(document.getElementById('463856212d1347558d919e4e179932db'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_463856212d1347558d919e4e179932db = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4f7f\\u7528\\u6700\\u591a\\u57ce\\u5e02\\u540d\\u4f5c\\u4e3a\\u8def\\u540d\\u7684\\u57ce\\u5e02\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d:\\u4e2a\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 110840,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                131.0,\n",
       "                89.0,\n",
       "                69.0,\n",
       "                64.0,\n",
       "                57.0,\n",
       "                56.0,\n",
       "                54.0,\n",
       "                49.0,\n",
       "                43.0,\n",
       "                42.0,\n",
       "                42.0,\n",
       "                41.0,\n",
       "                39.0,\n",
       "                39.0,\n",
       "                35.0\n",
       "            ],\n",
       "            \"stack\": \"stack_110840\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 110840\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 16\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u9752\\u5c9b\",\n",
       "                \"\\u4e0a\\u6d77\",\n",
       "                \"\\u53f0\\u5317\",\n",
       "                \"\\u5929\\u6d25\",\n",
       "                \"\\u6843\\u56ed\",\n",
       "                \"\\u9ad8\\u96c4\",\n",
       "                \"\\u957f\\u6625\",\n",
       "                \"\\u5c4f\\u4e1c\",\n",
       "                \"\\u6c88\\u9633\",\n",
       "                \"\\u53f0\\u4e1c\",\n",
       "                \"\\u53f0\\u4e2d\",\n",
       "                \"\\u82cf\\u5dde\",\n",
       "                \"\\u4e4c\\u9c81\\u6728\\u9f50\",\n",
       "                \"\\u70df\\u53f0\",\n",
       "                \"\\u4e91\\u6797\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_463856212d1347558d919e4e179932db.setOption(option_463856212d1347558d919e4e179932db);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e4cd19b0>"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"使用最多城市名作为路名的城市\",\"单位:个\", width = 800,height=500)\n",
    "bar.add(\"\", city_counts.index, city_counts.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=16, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside')\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {
    "id": "525008E8ED6D44A980D00FD1B7A88643",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "province_short\n",
       "山东     34\n",
       "台湾     26\n",
       "湖北     19\n",
       "上海     16\n",
       "江苏     16\n",
       "河北     15\n",
       "河南     15\n",
       "四川     13\n",
       "辽宁     13\n",
       "黑龙江    12\n",
       "北京     10\n",
       "吉林     10\n",
       "新疆     10\n",
       "西藏     10\n",
       "广东      9\n",
       "Name: prov_ext, dtype: int64"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用最多省名作为路名的省\n",
    "data.groupby('province_short')['prov_ext'].apply(get_unique_city_count).nlargest(15).to_csv('prov.csv')\n",
    "data.groupby('province_short')['prov_ext'].apply(get_unique_city_count).nlargest(15)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "4E24674360774B4A82FC317EF965938A",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.3 街、道、路、巷、胡同、里有何不同？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {
    "id": "585E0E06C9BE4E4CBE67C8E6C46C4FFA",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "data['road_clean'] = data['road'].str.extract(r\"(.*[街|道|路|巷|胡同|里])\")[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {
    "id": "95A2028D25C6431489217C906CEA00AE",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "data['endings'] = data['road_clean'].str.extract(r\".*(街|道|路|巷|胡同|里)\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {
    "id": "158C4C1DFEEE4D1887AA3D462A377F97",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "路     94788\n",
       "街     36588\n",
       "巷     10720\n",
       "道      7504\n",
       "胡同     1153\n",
       "里       421\n",
       "Name: endings, dtype: int64"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['endings'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "id": "E0DA3228BAFD4DD4B7635A75B3D4D702",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "\n",
    "url = 'https://restapi.amap.com/v3/geocode/geo?key=你申请的高德地图API Key&address={}&city={}'\n",
    "\n",
    "\n",
    "def get_latlon(data):\n",
    "    res = requests.get(url.format(data[5], data[0]))\n",
    "    if res.json()['status'] == '1':\n",
    "        item = res.json().get('geocodes')\n",
    "        if len(item) > 0:\n",
    "            return item[0].get('location')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {
    "id": "16F17599F7B34F1C87716C10C491EE27",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "# 胡同/里 都在哪里？\n",
    "hutong = data[data['endings'] == '胡同']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "983760E52906410C8056557236C767FA"
   },
   "outputs": [],
   "source": [
    "hutong['latlon'] = hutong.apply(get_latlon, axis=1)\n",
    "hutong.to_csv('hutong.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "D998766EFB22442A80B376D67240A3EA",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "li = data[data['endings'] == '里']\n",
    "li['latlon'] = li.apply(get_latlon, axis=1)\n",
    "li.to_csv('li.csv', index=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "B43BA449D11241A0AE5C28FCF4262E3B",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.4 各城市都有“建设路”吗？还有哪些具有时代特色的路名？\n",
    "工业、人民、光明、建设、胜利、文化、自强、朝阳、复兴、和平"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {
    "id": "383065C4C133445A8E4AFB3946CA79A0",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['保定', '成都', '沧州', '长治', '长春', '长沙', '常德', '大连', '德州', '鄂州', '佛山',\n",
       "       '抚州', '广州', '邯郸', '衡水', '哈尔滨', '呼伦贝尔', '杭州', '黄冈', '衡阳', '怀化',\n",
       "       '海口', '汉中', '海西', '晋中', '焦作', '锦州', '佳木斯', '济宁', '荆州', '江门', '开封',\n",
       "       '吕梁', '牡丹江', '马鞍山', '绵阳', '南京', '南阳', '南通', '宁波', '南昌', '南充', '内江',\n",
       "       '平顶山', '秦皇岛', '齐齐哈尔', '青岛', '上海', '沈阳', '石家庄', '商丘', '韶关', '深圳',\n",
       "       '石嘴山', '天津', '唐山', '通化', '武汉', '温州', '威海', '西安', '邢台', '新乡', '信阳',\n",
       "       '徐州', '孝感', '湘西', '西宁', '阳江', '永州', '宜宾', '重庆', '张家口', '淄博', '漳州',\n",
       "       '枣庄', '株洲', '肇庆', '湛江', '泸州', '屏东', '新北'], dtype=object)"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.loc[data['road'].str.contains('建设'), 'city'].unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "id": "32040E89A9C946A49FB8317235F73D1A",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "82"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data.loc[data['road'].str.contains('建设'), 'city'].unique())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "id": "4D7FF287AAE24733B1F1270CAD572648",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "data['era'] = data['road'].str.extract(r\"(工业|人民|光明|建设|胜利|文化|自强|朝阳|复兴|和平)\")[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {
    "id": "0173D94D55F0496E9BAD6EAF7C8A2145",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "工业    812\n",
       "文化    257\n",
       "人民    225\n",
       "建设    224\n",
       "和平    222\n",
       "光明    217\n",
       "复兴    191\n",
       "朝阳    174\n",
       "胜利    169\n",
       "自强    135\n",
       "Name: era, dtype: int64"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "era_top10 = data['era'].value_counts()\n",
    "era_top10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "id": "0667B1E1531B49F68827937853F23B2C",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"eae737eb243b4fd5a3f2647aa06dc9ee\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_eae737eb243b4fd5a3f2647aa06dc9ee = echarts.init(document.getElementById('eae737eb243b4fd5a3f2647aa06dc9ee'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_eae737eb243b4fd5a3f2647aa06dc9ee = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5e26\\u6709\\u65f6\\u4ee3\\u7279\\u8272\\u7684\\u8def\\u540d\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d: \\u4e2a\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 4498907,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                812.0,\n",
       "                257.0,\n",
       "                225.0,\n",
       "                224.0,\n",
       "                222.0,\n",
       "                217.0,\n",
       "                191.0,\n",
       "                174.0,\n",
       "                169.0,\n",
       "                135.0\n",
       "            ],\n",
       "            \"stack\": \"stack_4498907\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 4498907\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 16\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5de5\\u4e1a\",\n",
       "                \"\\u6587\\u5316\",\n",
       "                \"\\u4eba\\u6c11\",\n",
       "                \"\\u5efa\\u8bbe\",\n",
       "                \"\\u548c\\u5e73\",\n",
       "                \"\\u5149\\u660e\",\n",
       "                \"\\u590d\\u5174\",\n",
       "                \"\\u671d\\u9633\",\n",
       "                \"\\u80dc\\u5229\",\n",
       "                \"\\u81ea\\u5f3a\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#eb3b5a\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_eae737eb243b4fd5a3f2647aa06dc9ee.setOption(option_eae737eb243b4fd5a3f2647aa06dc9ee);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e62cf9b0>"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"带有时代特色的路名\",\"单位: 个\", width = 600,height=500)\n",
    "bar.add(\"\", era_top10.index, era_top10.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=16, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside', label_color=['#eb3b5a'])\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "C03173A8A4E64B008941DB077022F903",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "gongye = data[data['era'] == '工业']\n",
    "gongye['latlon'] = gongye.apply(get_latlon, axis=1)\n",
    "gongye.to_csv('gongye.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "16FCE17466024378855769113A23BBBC",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "wenhua = data[data['era'] == '文化']\n",
    "wenhua['latlon'] = wenhua.apply(get_latlon, axis=1)\n",
    "wenhua.to_csv('wenhua.csv', index=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "2FBEEB28C57B41918646E50C5F18D3BB",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.5 体现人们美好愿望的路名？\n",
    "成功、幸福、太平、永兴、兴业、创业、平安、仁爱、阳光、健康"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "id": "586C319BEF3143CF837CECD41357DF39",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "太平    175\n",
       "幸福    165\n",
       "成功    164\n",
       "永兴    124\n",
       "仁爱    122\n",
       "兴业     92\n",
       "平安     90\n",
       "创业     83\n",
       "健康     77\n",
       "阳光     76\n",
       "Name: wish, dtype: int64"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['wish'] = data['road'].str.extract(r\"(成功|幸福|太平|永兴|兴业|创业|平安|仁爱|阳光|健康)\")[0]\n",
    "wish_top10 = data['wish'].value_counts()\n",
    "wish_top10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "id": "7B1D83D8815143AB818705C17AB1E198",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"5b28197c15c94ffda0adcdf25062a371\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_5b28197c15c94ffda0adcdf25062a371 = echarts.init(document.getElementById('5b28197c15c94ffda0adcdf25062a371'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_5b28197c15c94ffda0adcdf25062a371 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4f53\\u73b0\\u4eba\\u6c11\\u7f8e\\u597d\\u613f\\u671b\\u7684\\u8def\\u540d\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d: \\u4e2a\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 7961821,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                175.0,\n",
       "                165.0,\n",
       "                164.0,\n",
       "                124.0,\n",
       "                122.0,\n",
       "                92.0,\n",
       "                90.0,\n",
       "                83.0,\n",
       "                77.0,\n",
       "                76.0\n",
       "            ],\n",
       "            \"stack\": \"stack_7961821\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 7961821\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 16\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u592a\\u5e73\",\n",
       "                \"\\u5e78\\u798f\",\n",
       "                \"\\u6210\\u529f\",\n",
       "                \"\\u6c38\\u5174\",\n",
       "                \"\\u4ec1\\u7231\",\n",
       "                \"\\u5174\\u4e1a\",\n",
       "                \"\\u5e73\\u5b89\",\n",
       "                \"\\u521b\\u4e1a\",\n",
       "                \"\\u5065\\u5eb7\",\n",
       "                \"\\u9633\\u5149\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#eb3b5a\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_5b28197c15c94ffda0adcdf25062a371.setOption(option_5b28197c15c94ffda0adcdf25062a371);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e4cd1240>"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"体现人民美好愿望的路名\",\"单位: 个\", width = 600,height=500)\n",
    "bar.add(\"\", wish_top10.index, wish_top10.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=16, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside', label_color=['#eb3b5a'])\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "id": "23DF0D2CFA18473ABB5958F950A75F33",
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "wish = data[data['wish'].isin(['太平', '幸福', '成功', '永兴', '仁爱'])]\n",
    "wish['latlon'] = wish.apply(get_latlon, axis=1)\n",
    "wish.to_csv('wish.csv', index=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "609E49425237475288C1D4AF620EC596",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.6 体现区域地理的路名？\n",
    "- 海、湖、江、河、涌、滘、潮、湾、港、溪、滨、洲、浦、洋、潭、沟、池\n",
    "- 岭、峰、山、田、泉、坪、埔、堤、坑、坝、屯"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "id": "DF9D2C309E704AFAA850D8F930683931"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "河    2702\n",
       "江    2594\n",
       "海    2394\n",
       "湖    2032\n",
       "港    1279\n",
       "溪    1119\n",
       "滨     744\n",
       "湾     617\n",
       "洲     505\n",
       "浦     499\n",
       "Name: water, dtype: int64"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['water'] = data['road'].str.extract(r\"(海|湖|江|河|涌|滘|潮|湾|港|溪|滨|洲|浦|洋|潭|沟|池)\")[0]\n",
    "water_top10 = data['water'].value_counts()[:10]\n",
    "water_top10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "id": "D35D934E3374432A8FA1E6AA8804A4EA",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"cf3641daf752401abd9e0d6160327606\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_cf3641daf752401abd9e0d6160327606 = echarts.init(document.getElementById('cf3641daf752401abd9e0d6160327606'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_cf3641daf752401abd9e0d6160327606 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8ddf\\u201c\\u6c34\\u201d\\u6709\\u5173\\u7684\\u8def\\u540d\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d: \\u4e2a\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 960716,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                2702.0,\n",
       "                2594.0,\n",
       "                2394.0,\n",
       "                2032.0,\n",
       "                1279.0,\n",
       "                1119.0,\n",
       "                744.0,\n",
       "                617.0,\n",
       "                505.0,\n",
       "                499.0\n",
       "            ],\n",
       "            \"stack\": \"stack_960716\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 960716\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 16\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u6cb3\",\n",
       "                \"\\u6c5f\",\n",
       "                \"\\u6d77\",\n",
       "                \"\\u6e56\",\n",
       "                \"\\u6e2f\",\n",
       "                \"\\u6eaa\",\n",
       "                \"\\u6ee8\",\n",
       "                \"\\u6e7e\",\n",
       "                \"\\u6d32\",\n",
       "                \"\\u6d66\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#eb3b5a\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_cf3641daf752401abd9e0d6160327606.setOption(option_cf3641daf752401abd9e0d6160327606);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e4cd4278>"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"跟“水”有关的路名\",\"单位: 个\", width = 600,height=500)\n",
    "bar.add(\"\", water_top10.index, water_top10.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=16, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside', label_color=['#eb3b5a'])\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "id": "CB1897E8BC5C4827A9048B2FBBC48923",
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  \n"
     ]
    }
   ],
   "source": [
    "water = data[data['water'].isin(['海', '湖', '港', '涌', '滘'])]\n",
    "water['latlon'] = water.apply(get_latlon, axis=1)\n",
    "water.to_csv('water.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {
    "id": "A1EEEDF2BAA54F5B81B6D61362088BC5",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "山    5164\n",
       "田     867\n",
       "岭     699\n",
       "峰     672\n",
       "埔     388\n",
       "坪     387\n",
       "堤     289\n",
       "坑     279\n",
       "屯     234\n",
       "坝     225\n",
       "Name: land, dtype: int64"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['land'] = data['road'].str.extract(r\"(岭|峰|山|田|坪|埔|堤|坑|坝|屯)\")[0]\n",
    "land_top10 = data['land'].value_counts()\n",
    "land_top10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "id": "574D884464B446B480590E578AF9F598",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"8126f63a27e74dfba1993404334712ff\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_8126f63a27e74dfba1993404334712ff = echarts.init(document.getElementById('8126f63a27e74dfba1993404334712ff'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_8126f63a27e74dfba1993404334712ff = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8ddf\\u201c\\u5c71/\\u5730/\\u5824\\u201d\\u6709\\u5173\\u7684\\u8def\\u540d\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d: \\u4e2a\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 196253,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                5164.0,\n",
       "                867.0,\n",
       "                699.0,\n",
       "                672.0,\n",
       "                388.0,\n",
       "                387.0,\n",
       "                289.0,\n",
       "                279.0,\n",
       "                234.0,\n",
       "                225.0\n",
       "            ],\n",
       "            \"stack\": \"stack_196253\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 196253\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 16\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5c71\",\n",
       "                \"\\u7530\",\n",
       "                \"\\u5cad\",\n",
       "                \"\\u5cf0\",\n",
       "                \"\\u57d4\",\n",
       "                \"\\u576a\",\n",
       "                \"\\u5824\",\n",
       "                \"\\u5751\",\n",
       "                \"\\u5c6f\",\n",
       "                \"\\u575d\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#eb3b5a\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_8126f63a27e74dfba1993404334712ff.setOption(option_8126f63a27e74dfba1993404334712ff);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e4cd4dd8>"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"跟“山/地/堤”有关的路名\",\"单位: 个\", width = 600,height=500)\n",
    "bar.add(\"\", land_top10.index, land_top10.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=16, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside', label_color=['#eb3b5a'])\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {
    "id": "35EEB7374B7C48BA8AC519365A902D3D",
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  \n"
     ]
    }
   ],
   "source": [
    "land = data[data['land'].isin(['田', '岭', '埔', '坑', '屯'])]\n",
    "land['latlon'] = land.apply(get_latlon, axis=1)\n",
    "land.to_csv('land.csv', index=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "C2321E61CD88459E9171DE8A412114DD",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.7 体现儒释道特色的路名？\n",
    "塔、庙、寺、仙、台、亭、圣、观、灵、宫"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "id": "A6F12887DE6D451C8E8144DE407A44E8",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "台    572\n",
       "塔    430\n",
       "庙    426\n",
       "仙    411\n",
       "亭    397\n",
       "寺    377\n",
       "圣    372\n",
       "观    305\n",
       "灵    295\n",
       "宫    190\n",
       "Name: religion, dtype: int64"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['religion'] = data['road'].str.extract(r\"(塔|庙|寺|仙|台|亭|圣|观|灵|宫)\")[0]\n",
    "religion_top10 = data['religion'].value_counts()\n",
    "religion_top10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {
    "id": "A66DFA0902A146AE9066D9F3E73E06BB",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"1798e1f35819455ebd4e599f3ed6ed78\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_1798e1f35819455ebd4e599f3ed6ed78 = echarts.init(document.getElementById('1798e1f35819455ebd4e599f3ed6ed78'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_1798e1f35819455ebd4e599f3ed6ed78 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u53d7\\u5112\\u91ca\\u9053\\u6587\\u5316\\u5f71\\u54cd\\u7684\\u8def\\u540d\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d: \\u4e2a\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 3617076,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                572.0,\n",
       "                430.0,\n",
       "                426.0,\n",
       "                411.0,\n",
       "                397.0,\n",
       "                377.0,\n",
       "                372.0,\n",
       "                305.0,\n",
       "                295.0,\n",
       "                190.0\n",
       "            ],\n",
       "            \"stack\": \"stack_3617076\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3617076\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 16\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u53f0\",\n",
       "                \"\\u5854\",\n",
       "                \"\\u5e99\",\n",
       "                \"\\u4ed9\",\n",
       "                \"\\u4ead\",\n",
       "                \"\\u5bfa\",\n",
       "                \"\\u5723\",\n",
       "                \"\\u89c2\",\n",
       "                \"\\u7075\",\n",
       "                \"\\u5bab\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#eb3b5a\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_1798e1f35819455ebd4e599f3ed6ed78.setOption(option_1798e1f35819455ebd4e599f3ed6ed78);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3e62f1da0>"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"受儒释道文化影响的路名\",\"单位: 个\", width = 600,height=500)\n",
    "bar.add(\"\", religion_top10.index, religion_top10.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=16, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside', label_color=['#eb3b5a'])\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {
    "id": "BA62CBD05CF64C7C981DCFB6B914B465",
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  \n"
     ]
    }
   ],
   "source": [
    "religion = data[data['religion'].isin(['塔', '庙', '仙', '寺', '圣'])]\n",
    "religion['latlon'] = religion.apply(get_latlon, axis=1)\n",
    "religion.to_csv('religion.csv', index=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "F1CB5A2E675147A19355933B4FDE071E",
    "mdEditEnable": false
   },
   "source": [
    "#### 3.8 体现周围景观的路名？\n",
    "- 林、梅、竹、杨、柳、莲、桃、李、杏、棉"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "id": "162E0FC345A446B38FD700638D536CC4",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "林    1505\n",
       "竹     632\n",
       "杨     581\n",
       "梅     492\n",
       "柳     423\n",
       "莲     403\n",
       "桃     330\n",
       "李     216\n",
       "杏     156\n",
       "棉      65\n",
       "Name: plant, dtype: int64"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['plant'] = data['road'].str.extract(r\"(林|梅|竹|杨|柳|莲|桃|李|杏|棉)\")[0]\n",
    "plant_top10 = data['plant'].value_counts()\n",
    "plant_top10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "id": "F0C189913AA6418F8BEDC0D54EE2A4D8",
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"04739437dd2048f5ad2cb1e017e46b3e\" style=\"width:600px;height:500px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_04739437dd2048f5ad2cb1e017e46b3e = echarts.init(document.getElementById('04739437dd2048f5ad2cb1e017e46b3e'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_04739437dd2048f5ad2cb1e017e46b3e = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4f53\\u73b0\\u5468\\u56f4\\u666f\\u89c2\\u7684\\u8def\\u540d\",\n",
       "            \"subtext\": \"\\u5355\\u4f4d: \\u4e2a\",\n",
       "            \"left\": \"auto\",\n",
       "            \"top\": \"auto\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 18\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"\\u4e0b\\u8f7d\\u56fe\\u7247\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 2102141,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"data\": [\n",
       "                1505.0,\n",
       "                632.0,\n",
       "                581.0,\n",
       "                492.0,\n",
       "                423.0,\n",
       "                403.0,\n",
       "                330.0,\n",
       "                216.0,\n",
       "                156.0,\n",
       "                65.0\n",
       "            ],\n",
       "            \"stack\": \"stack_2102141\",\n",
       "            \"barCategoryGap\": \"40%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 2102141\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 20\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": true,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": true\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 16\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u6797\",\n",
       "                \"\\u7af9\",\n",
       "                \"\\u6768\",\n",
       "                \"\\u6885\",\n",
       "                \"\\u67f3\",\n",
       "                \"\\u83b2\",\n",
       "                \"\\u6843\",\n",
       "                \"\\u674e\",\n",
       "                \"\\u674f\",\n",
       "                \"\\u68c9\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#eb3b5a\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_04739437dd2048f5ad2cb1e017e46b3e.setOption(option_04739437dd2048f5ad2cb1e017e46b3e);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x7fc3dea03b00>"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bar = Bar(\"体现周围景观的路名\",\"单位: 个\", width = 600,height=500)\n",
    "bar.add(\"\", plant_top10.index, plant_top10.values, is_stack=True,bar_category_gap='40%', \n",
    "       xaxis_label_textsize=20, yaxis_label_textsize=16, is_label_show=True,\n",
    "       is_convert=True, is_yaxis_inverse=True, label_pos='inside', label_color=['#eb3b5a'])\n",
    "bar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "id": "604A4CF3F26A4B3E8DC4B51A3EBDEC20",
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.6/site-packages/ipykernel_launcher.py:2: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  \n"
     ]
    }
   ],
   "source": [
    "plant = data[data['plant'].isin(['竹', '杨', '梅', '柳', '莲', '桃', '李', '杏', '棉'])]\n",
    "plant['latlon'] = plant.apply(get_latlon, axis=1)\n",
    "plant.to_csv('plant.csv', index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
